class Observer {
  constructor(data) {
    this.walk(data);
    // this.data = data;
  }

  walk(data) {
    if (!data || typeof data !== 'object') return 
    Object.keys(data).forEach(key => {
      this.defineReactive(data, key, data[key]);
    })
  }

  defineReactive(data, key, val) {
    const _this = this
    this.walk(val)
    Object.defineProperty(data, key, {
      get(){
        return val;
      },
      set(newval){
        if (newval === val) return
        val = newval
        _this.walk(newval)
      }
    })
  }

}